<template>
  <view id="myaddress">
    <view class="son" v-for="(item, i) in addressList" :key="i">
      <view class="left">
        <view class="sontit">{{ item.address }}</view>
        <view class="sonuser">
          <view class="name">{{ item.name }}</view>
          <view class="name">{{ item.sex }}</view>
          <view class="name">{{ item.phone }}</view>
        </view>
      </view>
      <image
        src="@/static/user/edit.png"
        class="right"
        mode="widthFix"
        @click="editAddress(i)"
      />
    </view>

    <view class="bot">
      <button class="botbut" @click="toaddress()">新增地址</button>
    </view>
  </view>
</template>

<script setup>
import { ref, computed } from "vue";
import { useStore } from "vuex";

const store = useStore();

const addressList = computed(() => {
  return store.getters.getAddressList;
});

// 跳转
const toaddress = () => {
  uni.navigateTo({
    url: "/pages/user/addaddress",
  });
};
const editAddress = (i) => {
  uni.navigateTo({
    url: `/pages/user/editaddress?index=${i}`,
  });
};
</script>


<style lang="scss">
#myaddress {
  width: 100%;
  height: 100vh;
  background-color: #f0f8fa;
  box-sizing: border-box;
  padding-top: 30rpx;
  .son {
    width: 94%;
    margin: auto;
    padding: 30rpx 20rpx;
    box-sizing: border-box;
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30rpx;
    .left {
      .sontit {
        font-size: 36rpx;
        font-weight: bold;
      }
      .sonuser {
        font-size: 26rpx;
        color: #98999a;
        display: flex;
        margin-top: 20rpx;
        .name {
          margin-right: 10rpx;
        }
      }
    }
    .right {
      width: 50rpx;
    }
  }
  .bot {
    width: 100%;
    height: 120rpx;
    background-color: #fff;
    position: fixed;
    bottom: 0;
    display: flex;
    align-items: center;
    .botbut {
      width: 80%;
      margin: auto;
      background-color: #adb838;
      color: #fff;
      border-radius: 50rpx;
    }
  }
}
</style>
